<div id="viewer-container"></div>
<div class="label-info">
  <div class="btn" onclick="add()">添加动画</div>
  <div class="btn" onclick="remove()">移除动画</div>
</div>
<script>
  let viewer
  let model
  let animaFun
  CTS.ready(() => {
    viewer = new CTS.Viewer('viewer-container') //初始化场景
    let modeloader = new CTS.ModelLoder(viewer)
    viewer.camera.position.set(0, 0, 2) //设置相机位置
    modeloader.loadModelToScene('resources/model/hello.glb', _model => {
      model = _model
      // 动画函数结构，用于全局的动画
      animaFun = () => model.object.rotation.y += 0.01
    })
  })

  function add() {
    viewer.addAnimate(animaFun)
  }

  function remove() {
    viewer.removeAnimate(animaFun)
  }
</script>
